class code2 {
    //约瑟夫环:list
    public int iceBreakingGame(int num, int target) {
        List<Integer> list = new ArrayList<>();
        //全部加入
        for(int i=0;i<num;i++) {
            list.add(i);
        }
        int rm = (target-1) % num;
        while(list.size() != 1) {
            list.remove(rm);
            rm = (rm+target-1)%list.size();
        }
        return list.get(0);
    }
}